﻿using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;

public class QueryFriendListRequest : BaseRequest
{
	private FriendListPanel _friendListPanel;
	
	protected override void Awake()
	{
		_controllerType = ControllerType.USER;
		_methodType = MethodType.QUERY_FRIEND_LIST;
		base.Awake();
	}

	// Use this for initialization
	void Start () {
		//组件初始化
		_friendListPanel = this.gameObject.GetComponent<FriendListPanel>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	public void SendRequest()
	{
		//该请求无需携带参数域，后端由SocketChannel来辨识
		NettyRequest nettyRequest = new NettyRequest();
		nettyRequest.controllerType = (int) _controllerType;
		nettyRequest.methodType = (int) _methodType;
		nettyRequest.data = "none";
		byte[] dataBytes = ConverterTool.SerialRequestObj(nettyRequest);
		UnityFacade.Instance.ClientManager.SendMsgToServer(dataBytes);
		
		
	}
	
	public override void OnResponse(string data)
	{
		JsonData respJsonData = JsonMapper.ToObject(data);
		_friendListPanel.HandleResponse(respJsonData);

	}

	
}
